import json
from datetime import datetime

from pytz import timezone

from client.redis_client import r
from dao.es_dao.schedule_es_dao import build_role
from model.wristband_models import LocationData
from utils.date_utils import timestamp_to_str_000z
from utils.geo_utils import is_point_in_geo_fence, format_polygon
from utils.mongo_util import db


async def save_location_redis(current_timestamp, location_data: LocationData):
    location_redis = {
        "lat": str(location_data.latitude),
        "lon": str(location_data.longitude),
        "fix": "BT",
        "fixedPosition": 1,
        "ctm": timestamp_to_str_000z(current_timestamp)
    }
    r.rpush('location_' + location_data['device_id'], json.dumps(location_redis))




